#include <QCoreApplication>
#include <iostream>
#include "biginteger.h"
using namespace std;
#include <iostream>
#include "EncryptDecrypt.h"
#include <QDebug>

/*网络
a=123正确的私匙加密:
Base64:YeNmshwUDX63sSN5OTpT7I6BmG2uRDhgFPBnsKCV/nVTuJcY1b3RO34XcIV6hEo30Sa2YbmZDfA85ge+eAZP/8VCg1D6kx6ADbdYjlUhf+6hBl66We3i/XXR3gI9ImMDbfjqevwvAhTxTjFMC1A7y4Lcvo6nhiiDkzuqEH2lwAlpC/Rz1NFow9I9itIsgY1LOMyxi5PuuG+IfQTKDLR2KJ2ZtvDRydsQuc895UHkPUoeBR2au1p47PZqF+j09mXC7KhhZrOdRo0Tw1nmAPmLcs+jEm9TDEYcFVz6cKGtZ4p1XEh8HciR8I3hV9g2389IlfDGLEqfeKjb97aEOCQzNA==
Hex：
\x61 \xe3 \x66 \xb2 \x1c \x14 \x0d \x7e
\xb7 \xb1 \x23 \x79 \x39 \x3a \x53 \xec
\x8e \x81 \x98 \x6d \xae \x44 \x38 \x60
\x14 \xf0 \x67 \xb0 \xa0 \x95 \xfe \x75
\x53 \xb8 \x97 \x18 \xd5 \xbd \xd1 \x3b
\x7e \x17 \x70 \x85 \x7a \x84 \x4a \x37
\xd1 \x26 \xb6 \x61 \xb9 \x99 \x0d \xf0
\x3c \xe6 \x07 \xbe \x78 \x06 \x4f \xff
\xc5 \x42 \x83 \x50 \xfa \x93 \x1e \x80
\x0d \xb7 \x58 \x8e \x55 \x21 \x7f \xee
\xa1 \x06 \x5e \xba \x59 \xed \xe2 \xfd
\x75 \xd1 \xde \x02 \x3d \x22 \x63 \x03
\x6d \xf8 \xea \x7a \xfc \x2f \x02 \x14
\xf1 \x4e \x31 \x4c \x0b \x50 \x3b \xcb
\x82 \xdc \xbe \x8e \xa7 \x86 \x28 \x83
\x93 \x3b \xaa \x10 \x7d \xa5 \xc0 \x09
\x69 \x0b \xf4 \x73 \xd4 \xd1 \x68 \xc3
\xd2 \x3d \x8a \xd2 \x2c \x81 \x8d \x4b
\x38 \xcc \xb1 \x8b \x93 \xee \xb8 \x6f
\x88 \x7d \x04 \xca \x0c \xb4 \x76 \x28
\x9d \x99 \xb6 \xf0 \xd1 \xc9 \xdb \x10
\xb9 \xcf \x3d \xe5 \x41 \xe4 \x3d \x4a
\x1e \x05 \x1d \x9a \xbb \x5a \x78 \xec
\xf6 \x6a \x17 \xe8 \xf4 \xf6 \x65 \xc2
\xec \xa8 \x61 \x66 \xb3 \x9d \x46 \x8d
\x13 \xc3 \x59 \xe6 \x00 \xf9 \x8b \x72
\xcf \xa3 \x12 \x6f \x53 \x0c \x46 \x1c
\x15 \x5c \xfa \x70 \xa1 \xad \x67 \x8a
\x75 \x5c \x48 \x7c \x1d \xc8 \x91 \xf0
\x8d \xe1 \x57 \xd8 \x36 \xdf \xcf \x48
\x95 \xf0 \xc6 \x2c \x4a \x9f \x78 \xa8
\xdb \xf7 \xb6 \x84 \x38 \x24 \x33 \x34
*/

int main1() {
    EncryptDecrypt encrypt_decrypt;
    encrypt_decrypt.reset(10);// 设置密钥长度

    char ch;
    std::string str;
    bool ok = true;

    do {
        encrypt_decrypt.menu();// 菜单显示
        std::cout << ">";
        std::cin >> str;
        if (str.empty()) {
            std::cout << "输入错误!请重新输入!" << std::endl;
            continue;
        }
        ch = str.at(0);
        switch(ch) {
        case 'e':
        case 'E':
//加密支付宝"a=123对应的sha256"8f6aee547fcc06a23022167f5555650ca9dbff8ae92773403171be9d943b9991
            if (!encrypt_decrypt.encrypt("613d313233a"))
                std::cout << "加密失败,请重试!" << std::endl;
            break;
        case 'd':
        case 'D':
            if (!encrypt_decrypt.decrypt("613d313233a"))
                std::cout << "解密失败,请重试!" << std::endl;
            break;
        case 'p':
        case 'P':
            encrypt_decrypt.print();// 打印相关信息
            break;
        case 'r':
        case 'R':
            encrypt_decrypt.reset(5);// 重新设置密钥长度
            break;
        case 'q':
        case 'Q':
            ok = false;    // 退出
            break;
        default:
            break;
        }
    } while (ok);
    return 0;
}
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    QString aa= "";
//QByteArray bb =QByteArray::fromHex (aa.toLatin1().data());
    //   text.data();            // returns "Qt is great!"
    //Bytearray转QString
//     QString aa =aa.prepend(text);
QString bb=QByteArray::fromBase64("MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC6c0aRrrnjDbocoRPLqX7cYqky6DJSgrHVYT0oDj+t2bWoTraULW3iw8q5OLSe6QYXM7QPOig4u+j/9m6CLnv0Hf896Mp9hw6Et8XPfTkSIzgvGlhabFs4qWEQx8CSanlzOEsHM+pTDFLpBbMtwkxPjfwgrxu35d5oFNk6mjlC/RoAhPL5zDucSL9NERg4nTeGMRQuASZlVGoHTz7F9+dGWPOw4ou3xwWwRJYWz8lSII+E41RggMpsoyYdnLKiwxv1yPTOjQ1m52gYrIobJKWY7Qve6wgcv6xEEpw37559H1wwGXxdhjCVMWCsmlpk7rDQX0FrIMYAMi7dinQU+f9xAgMBAAECggEAF5Q8eHAAUhaKUtSMDFWDFZvkieuTcZvVoYaKlWY352SA9Kf/rv2Px/26xXHGZdJSUtzXCJXyQDqDXNttXklCo7ynaszlzrolu+MBwRu0+/Y4RLywL79ESgYhoF2inOGaOlgEJQULvTTxx0ZRQpgvzl/GYtvCRZ9sYP1B+4dFdpMUMBUNRMYVDxy8mVgtfuOGbwdehS8GahUSMTGOz7/kwWyk3k9kaoDLxM7+HM2gUYtWfdW/hpxvWSVA50zm5aPkntrxcW8YGzqTjPyg1Do2dmRNnrMgeKzlHJyok6v3zzTHqTxkK0OT8SIv+jD4mW7VyTB3B2tm0QKMDqQ+vN9LgQKBgQDquKP5cJfF3v69CJGnohZ5MSzhEHBZHeGe4RpeG5uRKmNlLkC2FlLKweUkVGY65Sclxsw5+ar8SrBBCkWw3MteOm2aKA3ETroYsqC0tx/gDSSAwqxvfoA6fehpl7tXxX5WkQvgA7G/Oskf6c84hHJM9CnBNecYxiyxCJHvYIoF8wKBgQDLWl+S7moGYc4YUbGjRfBW9rDBD081Rpl09qWOliNc/MflJxJuCROqcvuGJt5HSQf9uMUlYwGbDohUYP+Wc5iJQsiQoYndCcMX0EunZyMVGEzeC2sZvHnUUnciToT4yAsQjh/6A5kpjCIKgoRf02gm0x7Crrm7LOH/xaQW9L7KCwKBgDhXN6zhNN0fKMBRNT0qsABJKH+hhYYuoQCVAdJDCDVxGkioMIpEk3zty8XLqHpMlPgBXvYvkrZaazJBd/b7GKm2lqZhJOTRDORuxBp8tl7+aJurnt5oW/kuTcJC1Io98pRu3o3X9St0veA2LDJhwFnuZbNl7+HHd+TKrNTrtFW3AoGBAJEuK0/WQQHfb+ly4bTkqMsdgmHDEVTC26pisR4UWJj5q6kRdRn0BwNI5gQH2efg3wComq+veKUAAhrjyXXbf4p3kIOZoLibUJq+zlRs0OItoCti0YrlQcFxQrbOgiavgx7FqVSwnvfHoUIJnoJfh1s4nRx27AkS6SLXMuhkwZWzAoGBAILBf3eeS2g40KXITbv3K1y9+doi0/r0W7HU07uQvIT8/g5xfeTKY3DCzk9xBlywm17nCDW4hXlIwiWcGLaR7zlX3HOoGU3Qqq6dlOBbFI8C0Osw70G2+kAkRp/d6MBAEp63d9Sv1D6mJNuoM7euYB0aFfndTQgmpUkLka9HhboT").toHex();
//QString cc=bb.toBase64();
//cc.prepend(bb);
     qDebug()<<bb;




     main1();
    return a.exec();
}
